﻿<UserControl x:Class="CmdletHelpEditor.UI.UserControls.RelatedLinksControl"
			 x:Name="RelatedLinks"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:c="clr-namespace:CmdletHelpEditor.Controls"
             d:DataContext="{d:DesignInstance c:ClosableTabItem}"
             mc:Ignorable="d">
	<DockPanel>
		<StackPanel DockPanel.Dock="Top"
                    IsEnabled="{Binding EditorContext.RelatedLinkContext.LinkTextBoxEnabled}"
                    Margin="10">
			<TextBlock Text="Related link:"/>
            <TextBox MaxLines="1"
                     Text="{Binding EditorContext.RelatedLinkContext.CurrentRelink.LinkText}"/>
            <TextBlock Text="URL (optional):"/>
            <TextBox MinLines="3"
                     MaxLines="3"
                     AcceptsReturn="False"
                     AcceptsTab="False"
                     Text="{Binding EditorContext.RelatedLinkContext.CurrentRelink.LinkUrl}"/>
        </StackPanel>
		<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
			<ListView x:Name="lvLinks"
					  Margin="10,0,10,0"
					  SelectedIndex="{Binding EditorContext.RelatedLinkContext.CurrentLinkIndex}"
					  SelectedItem="{Binding EditorContext.RelatedLinkContext.CurrentRelink}"
					  ItemsSource="{Binding EditorContext.CurrentCmdlet.RelatedLinks}"
					  Width="670"
					  Height="150">
				<ListView.View>
					<GridView>
						<GridViewColumn Header="Name"
                                        DisplayMemberBinding="{Binding LinkText}"
                                        Width="335"/>
						<GridViewColumn Header="Url"
                                        DisplayMemberBinding="{Binding LinkUrl}"
                                        Width="335"/>
					</GridView>
				</ListView.View>
			</ListView>
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition Height="10"/>
					<RowDefinition/>
				</Grid.RowDefinitions>
				<Button Grid.Row="0"
                        VerticalAlignment="Bottom"
                        Width="24"
                        IsEnabled="{Binding EditorContext.RelatedLinkContext.UpLinkEnabled}"
                        Command="{Binding EditorContext.RelatedLinkContext.UpLinkCommand}"
                        ToolTip="Move related link up">
					<Image Source="/Images/up_32x32.png"/>
				</Button>
				<Button Grid.Row="2"
                        VerticalAlignment="Top"
                        Width="24"
                        IsEnabled="{Binding EditorContext.RelatedLinkContext.DownLinkEnabled}"
                        Command="{Binding EditorContext.RelatedLinkContext.DownLinkCommad}"
                        ToolTip="Move related link down">
					<Image Source="/Images/down_32x32.png"/>
				</Button>
			</Grid>
		</StackPanel>
		<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="10">
			<Button Content="New"
                    Width="75"
                    Command="{Binding EditorContext.RelatedLinkContext.NewLinkCommand}"/>
			<Button Content="Remove"
                    Width="75"
                    IsEnabled="{Binding EditorContext.RelatedLinkContext.RemoveLinkEnabled}"
                    Command="{Binding EditorContext.RelatedLinkContext.RemoveLinkCommand}" Margin="10,0,0,0"/>
		</StackPanel>
	</DockPanel>
</UserControl>
